package 创建者模式.单例模式.懒汉式.双重检查锁模式;

public class Singleton {
    //1.私有构造方法
    private Singleton(){}
    //2.声明Singleton类型的变量instance
    private static Singleton instance;
    //3.对外提供访问方式
    public static Singleton getInstance(){
        if (instance==null){
            synchronized (Singleton.class) {
                if (instance == null)
                instance = new Singleton();
            }
        }
        return instance;
    }
}
